package com.yutel.security;

public class IDUtil {

	private int[] max = new int[] { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5,
			8, 4, 2 };
	private char[] min = new char[] { '1', '0', 'X', '9', '8', '7', '6', '5',
			'4', '3', '2' };

	public IDUtil() {

	}

	public static void main(String[] args) {
		IDUtil id = new IDUtil();
		id.vid("61032119810416181X");
	}

	public void vid(String id) {
		if (id == null || id.length() != 18) {
			return;
		}
		int sum = 0;
		char end = id.charAt(17);
		for (int i = 0; i < 17; i++) {
			char d = id.charAt(i);
			int ma = Integer.parseInt(Character.toString(d));
			sum += (ma * max[i]);
		}
		int mod = sum % 11;
		char dd = min[mod];
		if (end == dd) {
			System.out.println("id=" + id + ":true");
		} else {
			System.out.println("id=" + id + ":false");
		}
	}

}
